#!/bin/bash
for cpu_type in atomic timing; do
    echo "Running $cpu_type CPU..."
    ./gem5/build/RISCV/gem5.opt cpu_compare.py --cpu-type=$cpu_type
    cp m5out/stats.txt "stats_$cpu_type.txt"
done

# 提取关键指标
echo "CPU Model | Simulation Time (s) | MIPS "
echo "---------------------------------------------"
for cpu_type in atomic timing; do
    sim_sec=$(grep "hostSeconds" stats_$cpu_type.txt | awk '{print $2}')
    insts=$(grep "simInsts" stats_$cpu_type.txt | awk '{print $2}')
    mips=$(echo "scale=2; $insts / (10^6 * $sim_sec)" | bc)
    echo "$cpu_type | $sim_sec | $mips"
done
